<h2>Quản lý tin tức</h2>
<div class="content-box"><!-- Start Content Box -->
    <div class="content-box-header">
        <h3>Các bài viết</h3>
        <ul class="content-box-tabs">

			<li><a href="#tab1" class="default-tab">Tin đã đăng</a></li> <!-- href must be unique and match the id of target div -->
			<li><a href="#tab2">Tin chờ duyệt</a></li>
            
		</ul>
        
        <div class="clear"></div>
    </div> <!-- End .content-box-header -->
    <div class="content-box-content">
        <form name="frm_search_article" method="post" action="<?php echo Url::site('admin/article/search') ?>">
            <fieldset> <!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->
                <p>
                    <label>Từ khóa
                    <input type="text" name="keyword" class="text-input small-input" />
                    <input type="submit" name="submit" value="Tìm kiếm" class="button" /></label>
                </p>
            </fieldset>
        </form>
        <div class="tab-content default-tab" id="tab1"> <!-- This is the target div. id must match the href of this div's tab -->
<?php
if(isset ($articles) == TRUE && count($articles) > 0) :
?>
            <form name="frm_manage_article" method="post" action="<?php echo Url::site('admin/article/delete') ?>">
            <table>
                <thead>
                    <tr>
                        <th><input class="check-all" type="checkbox" /></th>
                        <th>Tiêu Đề</th>
                        <th>Danh Mục</th>
                        <th>Tóm Tắt</th>
                        <th>Ngày Đăng</th>
                        <th>Tác Vụ</th>
                    </tr>
                </thead>
                <tfoot>
                    <tr>
                        <td colspan="6">
                            <div class="bulk-actions align-left">
                                <input name="submit" value="Xóa bài đã chọn" type="submit" class="button" />
                                <?php echo $category->render() ?>
                                <input id="btn_view_by_category" value="Xem theo danh mục" type="button" class="button" />
                            </div>

                            <div class="pagination">
                                <?php if(isset ($pagination) == TRUE) $pagination->display() ?>
                            </div> <!-- End .pagination -->
                            <div class="clear"></div>
                        </td>
                    </tr>
                </tfoot>
                <tbody>
<?php
foreach($articles as $obj) :
?>
                    <tr>
                        <td><input type="checkbox" name="article_id[]" value="<?php echo $obj->id ?>" /></td>
                        <td><a href="<?php echo Url::site('admin/article/edit/' . $obj->id) ?>" title=""><?php echo $obj->title ?></a></td>
                        <td><?php echo $obj->Category->name ?></td>
                        <td><?php echo $obj->summary ?></td>
                        <td><?php echo date('d-m-Y H:i:s', $obj->created) ?></td>
                        <td>
                            <!-- Icons -->
                            <a href="<?php echo Url::site('admin/article/edit/' . $obj->id) ?>" title="Edit"><img src="<?php echo $assets_image . '/icons/pencil.png'; ?>" alt="Edit" /></a>
                            <a href="<?php echo Url::site('admin/article/delete/' . $obj->id) ?>" title="Xóa bài viết"><img src="<?php echo $assets_image . '/icons/cross.png'; ?>" alt="Xóa" /></a>
                        </td>
                    </tr>
<?php
endforeach;
?>
                </tbody>
            </table>
            </form>
<?php
else :
?>
            <p>Không có bài viết nào</p>
<?php
endif;
?>
        </div> <!-- End #tab1 -->
        
        <!-- Begin new tab2 -->
        <div class="tab-content" id="tab2">
            <?php
if(isset ($pending_articles) == TRUE && count($pending_articles) > 0) :
?>
            <form name="frm_manage_article" method="post" action="<?php echo Url::site('admin/article/delete') ?>">
            <table>
                <thead>
                    <tr>
                        <th><input class="check-all" type="checkbox" /></th>
                        <th>Tiêu Đề</th>
                        <th>Danh Mục</th>
                        <th>Tóm Tắt</th>
                        <th>Ngày Đăng</th>
                        <th>Tác Vụ</th>
                    </tr>
                </thead>
                <tfoot>
                    <tr>
                        <td colspan="6">
                            <div class="bulk-actions align-left">
                                <input name="submit" value="Xóa bài đã chọn" type="submit" class="button" />
                                <?php echo $category->render() ?>
                                <input id="btn_view_by_category" value="Xem theo danh mục" type="button" class="button" />
                            </div>

                            <div class="clear"></div>
                        </td>
                    </tr>
                </tfoot>
                <tbody>
<?php
foreach($pending_articles as $obj) :
?>
                    <tr>
                        <td><input type="checkbox" name="article_id[]" value="<?php echo $obj->id ?>" /></td>
                        <td><a href="<?php echo Url::site('admin/article/edit/' . $obj->id) ?>" title=""><?php echo $obj->title ?></a></td>
                        <td><?php echo $obj->Category->name ?></td>
                        <td><?php echo $obj->summary ?></td>
                        <td><?php echo date('d-m-Y H:i:s', $obj->created) ?></td>
                        <td>
                            <!-- Icons -->
                            <a href="<?php echo Url::site('admin/article/edit/' . $obj->id) ?>" title="Edit"><img src="<?php echo $assets_image . '/icons/pencil.png'; ?>" alt="Edit" /></a>
                            <a href="<?php echo Url::site('admin/article/delete/' . $obj->id) ?>" title="Xóa bài viết"><img src="<?php echo $assets_image . '/icons/cross.png'; ?>" alt="Xóa" /></a>
                        </td>
                    </tr>
<?php
endforeach;
?>
                </tbody>
            </table>
            </form>
<?php
else :
?>
            <p>Không có bài viết nào</p>
<?php
endif;
?>
            
        </div> <!-- End tab2 -->
    </div> <!-- End .content-box-content -->
</div> <!-- End .content-box -->
<script type="text/javascript">
$(function(){
    Sidebar.setActive(Sidebar.menu.article, 1);

    $('#btn_view_by_category').click(function() {
        _id = $('select[name=category_id]').val();
        _url = '<?php echo Url::site('admin/article/category') ?>/' + _id;
        window.location = _url;
    });
});
</script>